/**
 * 
 */
package com.org.bu.app.jms.receiver;

import javax.jms.Message;
import javax.jms.TextMessage;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.jms.core.JmsTemplate;

/**
 * @author vk
 * 
 */
public class AMQReceiver implements JmsReceiver {

	private JmsTemplate jmsTemplate;

	private ActiveMQQueue queue;

	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}

	public void setQueue(ActiveMQQueue queue) {
		this.queue = queue;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.org.bu.app.jms.receiver.JmsReceiver#processMessage()
	 */
	public void processMessage() {
		Message msg = jmsTemplate.receive(queue);
		try {
			TextMessage textMessage = (TextMessage) msg;
			if (msg != null) {
				System.out.println(" Message Received -->" + textMessage.getText());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
